<template>
  <CloudDialog
    v-model:visible="visible"
    title="日志"
    :width="800"
    :mask-closable="false"
    :ok="handleCancel"
    :before-open="handleBeforeOpen"
    :cancel="handleCancel">
    <CloudScrollbar class="log-wrap">
      2024/09/12 17:02:21 开始申请证书,域名 [test.21508002.xyz] 申请方式 [HTTP]
      2024/09/12 17:02:21 [INFO] [test.21508002.xyz] acme: Obtaining bundled SAN
      certificate 2024/09/12 17:02:23 [INFO] [test.21508002.xyz] AuthURL:
      https://api.buypass.com/acme/authz/eeJCYM65veLVhZgjLR99Zz9hS9R87mh2RSKWHb4zmuk
      2024/09/12 17:02:23 [INFO] [test.21508002.xyz] acme: authorization already
      valid; skipping challenge 2024/09/12 17:02:23 [INFO] [test.21508002.xyz]
      acme: Validations succeeded; requesting certificates 2024/09/12 17:02:27
      [INFO] [test.21508002.xyz] Server responded with a certificate. 2024/09/12
      17:02:27 申请 [test.21508002.xyz] 证书成功！！ 2024/09/12 17:02:21
      开始申请证书,域名 [test.21508002.xyz] 申请方式 [HTTP] 2024/09/12 17:02:21
      [INFO] [test.21508002.xyz] acme: Obtaining bundled SAN certificate
      2024/09/12 17:02:23 [INFO] [test.21508002.xyz] AuthURL: 17:02:27 申请
      [test.21508002.xyz] 证书成功！！ 2024/09/12 17:02:21 开始申请证书,域名
      [test.21508002.xyz] 申请方式 [HTTP] 2024/09/12 17:02:21 [INFO]
      [test.21508002.xyz] acme: Obtaining bundled SAN certificate 2024/09/12
      17:02:23 [INFO] [test.21508002.xyz] AuthURL:
      https://api.buypass.com/acme/authz/eeJCYM65veLVhZgjLR99Zz9hS9R87mh2RSKWHb4zmuk
      2024/09/12 17:02:23 [INFO] [test.21508002.xyz] acme: authorization already
      valid; skipping challenge 2024/09/12 17:02:23 [INFO] [test.21508002.xyz]
      acme: Validations succeeded; requesting certificates 2024/09/12 17:02:27
      [INFO] [test.21508002.xyz] Server responded with a certificate. 2024/09/12
      17:02:27 申请 [test.21508002.xyz] 证书成功！！ 2024/09/12 17:02:21
      开始申请证书,域名 [test.21508002.xyz] 申请方式 [HTTP] 2024/09/12 17:02:21
      [INFO] [test.21508002.xyz] acme: Obtaining bundled SAN certificate
      2024/09/12 17:02:23 [INFO] [test.21508002.xyz] AuthURL:
      https://api.buypass.com/acme/authz/eeJCYM65veLVhZgjLR99Zz9hS9R87mh2RSKWHb4zmuk
      2024/09/12 17:02:23 [INFO] [test.21508002.xyz] acme: authorization already
      valid; skipping challenge 2024/09/12 17:02:23 [INFO] [test.21508002.xyz]
      acme: Validations succeeded; requesting certificates 2024/09/12 17:02:27
      [INFO] [test.21508002.xyz] Server responded with a certificate. 2024/09/12
      17:02:27 申请 [test.21508002.xyz] 证书成功！！
    </CloudScrollbar>
    <template #footer>
      <a-button @click="handleDownload">下载日志</a-button>
    </template>
  </CloudDialog>
</template>
<script lang="ts" setup>
import { useInterval } from '@vueuse/core'

const visible = defineModel<boolean>('visible', { required: true })
// const formState = reactive({
//   site_id: ''
// })
const getLog = () => {}
const { pause, resume } = useInterval(3000, {
  callback: getLog,
  immediate: true,
  controls: true
})
const handleBeforeOpen = async () => {
  resume()
}
const handleCancel = () => {
  pause()
}
const handleDownload = () => {
  // const data = `2`
  // const url = URL.createObjectURL(new Blob([data], { type: 'text/plain' }))
  // const a = document.createElement('a')
  // a.href = url
  // a.download = 'log.txt'
  // a.click()
  // URL.revokeObjectURL(url)
  // a.remove()
}
</script>
<style lang="less" scoped>
.log-wrap {
  background-color: var(--color-text-1);
  @apply h-85! p-4 text-white rounded;
}
</style>
